﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_type_fv.ascx.vb" Inherits="Apps_Shares_Uc_type_fv" %>
<asp:FormView ID="fv" runat="server" DefaultMode="Insert" RenderOuterTable="False"
    DataSourceID="fvSrc" EnableModelValidation="True" Width="100%">
    <InsertItemTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#cccccc" border="1" align="center"
            width="60%">
            <tbody>
                <tr>
                    <td bgcolor="#999999" align="center" class="th_data" colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อประเภทของการจัดการ <span class="star">*</span> :
                    </td>
                    <td align="left" class="td_box">
                        <asp:TextBox ID='txtTypeName' runat='server' CssClass='text_normal' Text='<%# Bind("type_name") %>'></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        สถานะ <span class="star">*</span> :
                    </td>
                    <td align="left" class="td_box">
                        <asp:RadioButtonList ID='rblStatus' runat='server' RepeatDirection="Horizontal" RepeatLayout='Flow'
                            SelectedValue='<%# Bind("type_status") %>'>
                            <asp:ListItem Text='ใช้งาน' Value='1' Selected='True'></asp:ListItem>
                            <asp:ListItem Text='ไม่ใช้งาน' Value='2'></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#999999" align="center" class="td_data_end" colspan="2">
                        <asp:Button ID='btnUpdate' runat='server' Text='บันทึก' CommandName="Insert" ValidationGroup='g1' />
                        <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
                        <div class="hide">
                            <asp:RequiredFieldValidator ID="txtTypeNameRequiredFieldValidator" runat="server"
                                ControlToValidate="txtTypeName" ErrorMessage="กรุณากรอกชือประเภทของการจัดการข้อมูล"
                                ValidationGroup="g1"></asp:RequiredFieldValidator>
                            <br />
                            <asp:RequiredFieldValidator ID="rblStatusRequiredFieldValidator" runat="server" ControlToValidate="rblStatus"
                                ErrorMessage="<%$ Resources:Resource, MSG_REQ_STATUS %>" ValidationGroup="g1"></asp:RequiredFieldValidator>
                            <br />
                            <asp:ValidationSummary ID="fvValidationSummary" runat="server" ValidationGroup='g1'
                                ShowMessageBox="True" />
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </InsertItemTemplate>
    <EditItemTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#cccccc" border="1" align="center"
            width="60%">
            <tbody>
                <tr>
                    <td bgcolor="#999999" align="center" class="th_data" colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อประเภทของการจัดการ <span class="star">*</span> :
                    </td>
                    <td align="left" class="td_box">
                        <asp:TextBox ID='txtTypeName' runat='server' CssClass='text_normal' Text='<%# Bind("type_name") %>'></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        สถานะ <span class="star">*</span> :
                    </td>
                    <td align="left" class="td_box">
                        <asp:RadioButtonList ID='rblStatus' runat='server' RepeatDirection="Horizontal" RepeatLayout='Flow'
                            SelectedValue='<%# Bind("type_status") %>'>
                            <asp:ListItem Text='ใช้งาน' Value='1' Selected='True'></asp:ListItem>
                            <asp:ListItem Text='ไม่ใช้งาน' Value='2'></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อและวันเวลาที่สร้างข้อมูล :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='ltrCreate' runat='server' Text='<%# Eval("Creator") %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อและวันเวลาที่ปรับปรุงข้อมูล :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='ltrUpdate' runat='server' Text='<%# Eval("Editor") %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#999999" align="center" class="td_data_end" colspan="2">
                        <asp:Button ID='btnUpdate' runat='server' Text='บันทึก' CommandName="Update" ValidationGroup="g1" />
                        <asp:Button ID='btnCancel' runat='server' Text='ยกเลิก' PostBackUrl="~/Apps/type_list.aspx?Edit=true" />
                        <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
                        <div class="hide">
                            <asp:RequiredFieldValidator ID="txtTypeNameRequiredFieldValidator" runat="server"
                                ControlToValidate="txtTypeName" ErrorMessage="กรุณากรอกชือประเภทของการจัดการข้อมูล"
                                ValidationGroup="g1"></asp:RequiredFieldValidator>
                            <br />
                            <asp:RequiredFieldValidator ID="rblStatusRequiredFieldValidator" runat="server" ControlToValidate="rblStatus"
                                ErrorMessage="<%$ Resources:Resource, MSG_REQ_STATUS %>" ValidationGroup="g1"></asp:RequiredFieldValidator>
                            <br />
                            <asp:ValidationSummary ID="fvValidationSummary" runat="server" ShowMessageBox="True"
                                ValidationGroup='g1' />
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </EditItemTemplate>
    <ItemTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#cccccc" border="1" align="center"
            width="60%">
            <tbody>
                <tr>
                    <td bgcolor="#999999" align="center" class="th_data" colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อประเภทของการจัดการ :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='txtTypeName' runat='server' Text='<%# Bind("type_name") %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        สถานะ :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='ltrTypeStatus' runat='server' Text='<%# CodeMatrix.Business.GenericData.GetStatusLabel(Eval("type_status")) %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อและวันเวลาที่สร้างข้อมูล :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='ltrCreate' runat='server' Text='<%# Eval("Creator") %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="td_box">
                        ชื่อและวันเวลาที่ปรับปรุงข้อมูล :
                    </td>
                    <td align="left" class="td_box">
                        &nbsp;
                        <asp:Literal ID='ltrUpdate' runat='server' Text='<%# Eval("Editor") %>'></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#999999" align="center" class="td_data_end" colspan="2">
                        <asp:Button ID='btnCancel' runat='server' Text='ย้อนกลับ' PostBackUrl="~/Apps/type_list.aspx" />
                        <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
                    </td>
                </tr>
            </tbody>
        </table>
    </ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="fvSrc" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
    SelectCommand="
        select	
                * ,
		        Creator = dbo.UFN_GetAuditor(staff_code_create,create_datetime),
		        Editor = dbo.UFN_GetAuditor(staff_code_update,update_datetime)
        from 	master_type
        where	type_code = @type_code" 
    InsertCommand=" insert into master_type ([type_name],[type_status],[staff_code_create],[create_datetime],[staff_code_update],[update_datetime])
                    values (@type_name,@type_status,@staff_code,getdate(),@staff_code,getdate());" 
    UpdateCommand=" update	master_type
                    set		[type_name] = @type_name ,
		                    type_status = @type_status ,
		                    staff_code_update = @staff_code ,
		                    update_datetime = getdate()
                    where	type_code = @type_code">
    <InsertParameters>
        <asp:SessionParameter Name="staff_code" SessionField="staff_code" DefaultValue='1' />
    </InsertParameters>
    <SelectParameters>
        <asp:QueryStringParameter Name="type_code" QueryStringField="Edit" />
    </SelectParameters>
    <UpdateParameters>
        <asp:SessionParameter Name="staff_code" SessionField="staff_code" />
        <asp:QueryStringParameter Name="type_code" QueryStringField="Edit" />
    </UpdateParameters>
</asp:SqlDataSource>
